<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>

</body>
<script>
    $(document).ready(function () {
        $.ajax({
            url: "http://127.0.0.1:8000/api/test",
            type: "get",
            data: {
                stock_code: "000004",
                model: "cnn",
                length: 365 * 2
            },
            success: function (res) {
                let arr = []
                let trendArr = []

                trendArr.push(["Income", "Country", "Year"])
                let length = res.data.close.length;
                for (let i = 0; i < length; i++) {
                    let arr1 = []
                    let arr2 = []
                    arr1.push(res.data.trade_date[i])
                    arr1.push(res.data.open[i])
                    arr1.push(res.data.close[i])
                    arr1.push(res.data.low[i])
                    arr1.push(res.data.high[i])

                    arr.push(arr1)

                    if (i < length - 100) continue
                    arr2.push(res.data.close[i])
                    arr2.push(res.data.ts_code[0])
                    arr2.push(res.data.trade_date[i])

                    trendArr.push(arr2)
                }
                let temp = [...trendArr[trendArr.length - 1]]
                temp[1] = "预测"
                trendArr.push(temp)
                trendArr.push([res.predict, "预测", res.next_day])
                console.log(arr)
                localStorage.setItem("data", JSON.stringify(arr))
                localStorage.setItem("stockCode", res.data.ts_code[0])
                localStorage.setItem("trend", JSON.stringify(trendArr))
                localStorage.setItem("predict", res.predict)
                localStorage.setItem("nextDay", res.next_day)
            }
        })
    })
</script>
</html>
